<?php
/*
  product_questions.php
  lists all questions and answers for a  particular product
  by surya
*/
  require('includes/application_top.php');
  require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_PRODUCT_QUESTIONS);
  if (!isset($HTTP_GET_VARS['products_id']) || !is_numeric($HTTP_GET_VARS['products_id'])) 
  {
    tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params()));
  } 	
	$product_query = tep_db_query("select pd.products_id, pd.products_name from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCT_QUESTIONS . " pq where pq.product_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = pq.product_id and pd.language_id = '" . (int)$languages_id . "'");
	if (!tep_db_num_rows($product_query)) 
 	{
		$productname = '';
  	} 
	else 
	{
    	$product_info = tep_db_fetch_array($product_query);
		$productname = $product_info['products_name'];
  	}
  $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_PRODUCT_QUESTIONS, 'products_id=' . $HTTP_GET_VARS['products_id']));
  require(DIR_WS_INCLUDES . 'template_top.php'); 
?>

<h1><?php //echo HEADING_TITLE; ?></h1>

<div class="contentContainer">
  <div class="contentText">
     <font style="font-size:12px;"><?php echo HEADING_CONTENT. '<b><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $product_info['products_id']) . '">'.$productname . '</a></b>'; ?></font>
	 
	 
	 <?php
	 $questions_query = "select * from  " . TABLE_PRODUCT_QUESTIONS . " where product_id='" . $HTTP_GET_VARS['products_id'] . "' and status='1' order by date_added";
     $questions_split = new splitPageResults($questions_query, MAX_DISPLAY_PRODUCT_QUESTIONS);
     if ($questions_split->number_of_rows > 0) 
	 {
		 $questions_query = tep_db_query($questions_split->sql_query);   
		 
		 $page = (isset($HTTP_GET_VARS['page']))?$HTTP_GET_VARS['page']:'1';
		 $max = MAX_DISPLAY_PRODUCT_QUESTIONS;
		 $i = ($max*$page)-($max-1); 
	
		 while($questions = tep_db_fetch_array($questions_query)) 
		 { 
		 echo '<table border="0" cellpadding="0" cellspacing="0" width="95%" align="center">';
		 echo '<tr><td>' .$i . '. ' . $questions['question'].' &nbsp;&nbsp;by '.$questions['customer_name'].'</td></tr>';
		 echo '<tr><td>'.$questions['answer'].'</td></tr>';
		 echo '</table>';
		 $i++;
		 }
	 } 
	 else 
	 {
	 	echo 'no questions';
	 }
	 if (($questions_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3'))) 
	 {
	 ?>

		  <div class="contentText">
			<p style="float: right;"><?php echo TEXT_RESULT_PAGE . ' ' . $questions_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info'))); ?></p>
		
			<p><?php echo $questions_split->display_count(TEXT_DISPLAY_NUMBER_OF_QUESTIONS); ?></p>
		  </div>
	<?php
	  }
	?>
	 
  </div>
  <div class="buttonSet">
        <?php echo tep_draw_button(IMAGE_BUTTON_BACK, 'triangle-1-w', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params())); ?>
		<?php echo '<a style="color:#990000; font-weight:bold; text-decoration:none; font-size:13px; float:right;" href="' . tep_href_link(FILENAME_ASK_QUESTION, 'products_id='.$HTTP_GET_VARS['products_id']) . '">' . TEXT_ASK_QUESTION . '</a>';?>
  </div>
</div>

<!-- body_eof //-->
<?php
  require(DIR_WS_INCLUDES . 'template_bottom.php');
  require(DIR_WS_INCLUDES . 'application_bottom.php');
?>